<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script crossorigin="anonymous" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <style>
        #result {
            width: 200px;
            height: 100px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <button>点击发送请求</button>
    <div id="result"></div>
    <script>
        
        $("button").eq(0).click(function() {
            // 下面的url是固定写法，需要传入一个callback参数
            $.getJSON("http://127.0.0.1:8000/jquery-jsonp-server?callback=?", function(data) {
                // console.log(data);
                $("#result").html(`
                    name: ${data.name}<br />
                    city: ${data.city}
                `);
            });
        });

        
        
    </script>
</body>
</html>